class BitField {
  final int value;

  BitField(this.value);

  // 获取单个bit
  int operator [](int index) => (value >> index) & 1;

  // 获取bit范围
  int range(int start, int end) {
    int bitCount = end - start + 1;
    int mask = (1 << bitCount) - 1;
    return (value >> start) & mask;
  }

  // 转换为二进制字符串
  String toBinaryString() {
    return value.toRadixString(2).padLeft(32, '0');
  }
}